package org.cy.shixun.controller;


import org.cy.shixun.dto.GoodsDto;
import org.cy.shixun.entity.Goods;
import org.cy.shixun.service.GoodsService;
import org.cy.shixun.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 类名称：GoodsController
 * 描述：商品管理
 *
 * @author: cy
 * @data: 2023/06/29
 */
@CrossOrigin
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    @GetMapping("category")
    public R category(String category){
        if(category==null){
            return R.error("分类为空");
        }
        List<Goods> category1 = goodsService.category(category);
        return R.success(category1);
    }

    @GetMapping("/item")
    public R item(int id){
        GoodsDto item = goodsService.item(id);
        return R.success(item);
    }
}

